import axios from '@/ajax/config'
import { OssType } from '@/constant/resApi'

/**
 * @param param
 * @returns {PromiseLike<T | never> | Promise<T | never> | *}
 */

// 选择员工
export function getUserSelectList(params?: any) {
  return axios.get('/scrm-api/sms/user/select', params)
}

// 上传文件
export async function doUploadFile(params: any) {
  const res: any = await axios.post('/scrm-api/sms/get-upload-param', params)
  if (!res.host) return
  console.log('res: ', res)
  const form = new FormData()
  console.log(params, 'paramsparams')
  form.append('key', res.dir)
  form.append('policy', res.policy)
  form.append('OSSAccessKeyId', res.accessid)
  form.append('callback', res.callback)
  form.append('signature', res.signature)
  form.append('expire', res.expire)
  form.append('success_action_status', '200')
  form.append('file', params.file)
  return axios.post(res.host, form, { isOss: true, headers: { 'Content-Type': 'multipart/form-data' } })
}
// 分组
export function getGroupList(params?: any) {
  return axios.get('/scrm-api/sms/group/list', params)
}
// 添加分组
export function createGroup(data?: any) {
  return axios.post('/scrm-api/sms/group/create', data)
}
// 删除分组
export function delGroup(data?: any) {
  return axios.post('/scrm-api/sms/group/del', data)
}
// 编辑分组
export function editGroup(data?: any) {
  return axios.post('/scrm-api/sms/group/update', data)
}
